using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class req_test_resultsMap : EntityTypeConfiguration<req_test_results>
    {
        public req_test_resultsMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.result_nm)
                .HasMaxLength(50);

            this.Property(t => t.value)
                .HasMaxLength(50);

            this.Property(t => t.unit)
                .HasMaxLength(15);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("req_test_results");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.result_nm).HasColumnName("result_nm");
            this.Property(t => t.value).HasColumnName("value");
            this.Property(t => t.req_test_id).HasColumnName("req_test_id");
            this.Property(t => t.item_res_id).HasColumnName("item_res_id");
            this.Property(t => t.normal_min).HasColumnName("normal_min");
            this.Property(t => t.normal_max).HasColumnName("normal_max");
            this.Property(t => t.unit).HasColumnName("unit");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.ReqTestRes_UserID).HasColumnName("ReqTestRes_UserID");

            // Relationships
            this.HasOptional(t => t.item_res)
                .WithMany(t => t.req_test_results)
                .HasForeignKey(d => d.item_res_id);
            this.HasOptional(t => t.req_tests)
                .WithMany(t => t.req_test_results)
                .HasForeignKey(d => d.req_test_id);

        }
    }
}
